<#include "/admin/common/include/html_head.html"> <#include
"/admin/common/include/sysparam.html"> <#include
"/admin/common/include/pagination.html">
<div class="row-fluid">
	<div class="span12">
		<!-- BEGIN EXTRAS PORTLET-->
		<div class="portlet box">
			<div class="portlet-title">
				<div class="caption">
					<h5>图片上传</h5>
				</div>
			</div>
			<div class="portlet-body form">
				<div class="alert alert-error " id="errtip" style="display: none;"></div>

				<!-- BEGIN FORM-->
				<form action="${contextPath}/image/save.op" id="bannerAddForm"
					class="form-horizontal" method="post">
					<input type="hidden" name="id" value="${(bean.id)?if_exists}" />
				 
					<div class="control-group">
						<label class="control-label">图片描述（可选）<span class="required">*</span></label>
						<div class="controls">
							<input type="text" name="name" id="name" class="span3 m-wrap"
								value="${(bean.name)?if_exists}" />
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">图片</label>
						<div class="controls">
							<#if bean?? && bean.imageUrl ?? > <img
								src="${contextPath}${(bean.imageUrl)?if_exists}" width="150"
								height="150" id="imgShow" alt="Photo" /> <#else> <img
								src="${contextPath}/common/image/default-pic.png" width="150"
								height="150" id="imgShow" /> </#if>

						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls">
							<span class="btn  fileinput-button"> <i
								class="icon-plus icon-white"></i> <span>选择文件...</span> <input
								type="file" id="upfile1" name="upfile1" />
							</span> <input type="hidden" id="imageUrl" name="imageUrl"
								value="${(bean.imageUrl)?if_exists}" /> <a class="btn start"
								onclick="uploadNavPic();"> <i class="icon-upload icon-white"></i>
								<span>上传</span>
							</a> <br> <span class="alert alert-error" id="upfile1_error_tip"
								style="display: none;"></span>
							<div class="alert alert-success" id="upfile1_detail"
								style="display: none;">
								<div class="fileName">
									文件名称:<span></span>
								</div>
								<div class="fileSize">
									文件大小:<span></span>
								</div>
							</div>

						</div>
					</div>
				  	<div class="control-group">
						<label class="control-label">图片地址</label>
						<div class="controls">
						<input type="text"   class="span3 m-wrap"
								value="${(bean.imageUrl)?if_exists}" readonly="readonly"/> 
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">是否有效<span class="required">*</span></label>
						<div class="controls"><@select2 paramCode=iseffCode
							value=(bean.iseff)?if_exists item=' name="iseff" require="true"
							datatype="require" msg="是否有效不能为空"'/></div>
					</div>

					<div class="form-actions">
						<button type="button" id="banner_save_btn" class="btn blue">保存</button>
						<button type="button" id="banner_return_btn" class="btn ">返回</button>
					</div>
				</form>

			</div>
			<!-- END EXTRAS PORTLET-->
		</div>
	</div>
</div>

<script>
	function uploadNavPic() {
		ajax.upload({
			fileEleId : 'upfile1',
			filePathId : 'imageUrl',
			successFn : function(data) {
				var isImg = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/
						.test(data.result.webfilePath);
				if (isImg)
					$('#imgShow').attr("src", data.result.webfilePath);
			}
		}) 
	}
	
	
	  
	jQuery(document)
			.ready(
					function() { 
						tableAction
								.initSaveAction({
									formId : 'bannerAddForm',
									queryUrl : '${contextPath}/image/show.op',
									saveUrl : '${contextPath}/image/save.op',
									saveBtnId : 'banner_save_btn'  
								});

						$("#banner_return_btn")
								.bind(
										"click",
										function() {
											var url = '${contextPath}/image/show.op';
											mainFrame.addContainer(url);
										});

					});
</script>
<#include "/admin/common/include/html_bottom.html">
